import { createBrowserRouter } from "react-router-dom";

let lazyHome = async () => {
  const { default: Home } = await import("../pages/tabs/Home");
  return {
    element: <Home />,
  };
};
let router = createBrowserRouter([
  {
    path: "/",
    async lazy() {
      const { default: App } = await import("../App");
      return {
        element: <App />,
      };
    },
    children: [
      {
        index: true,
        lazy: lazyHome,
      },
      {
        path: "home",
        lazy: lazyHome,
      },
      {
        path: "chat",
        async lazy() {
          const { default: Chat } = await import("../pages/tabs/Chat");
          return {
            element: <Chat />,
          };
        },
      },
      {
        path: "order",
        async lazy() {
          const { default: Order } = await import("../pages/tabs/Order");
          return {
            element: <Order />,
          };
        },
      },
      {
        path: "vip",
        async lazy() {
          const { default: Vip } = await import("../pages/tabs/Vip");
          return {
            element: <Vip />,
          };
        },
      },
      {
        path: "my",
        async lazy() {
          const { default: My } = await import("../pages/tabs/My");
          return {
            element: <My />,
          };
        },
      },
    ],
  },
  {
        path: "/city/:type",
        async lazy() {
          const { default: City,loader } = await import("../pages/city/index");
          return {
            element: <City />,
            loader
          };
        },
      },
]);
export default router;
